package cate.game.role.bag.newtalent.msg;


import cate.common.annotation.OperationSetter;
import cate.common.table.d.GDOperation;
import cate.common.util.GameResult;
import cate.game.GameBody;
import cate.game.client.ClientContext;
import cate.game.client.msg.ClientMsg;
import cate.game.client.msg.MsgConfig;
import cate.game.client.msg.MsgInput;
import cate.game.client.msg.id.MsgIdBHeroTalent;
import cate.game.role.bag.hero.Hero;
import easy.java.dev.note.NoteField;

@ClientMsg(title = "天赋遗忘 の 请求")
@OperationSetter(GDOperation.FORGET_TALENT)
public class TalentForgetReq implements MsgInput {

    @NoteField("所选英雄的唯一ID")
    public String heroIdHex;
    @NoteField("天赋的唯一ID")
    public String talentIdHex;

    @Override
    public void execute(GameBody game, ClientContext cc) {
        Hero hero = cc.getRole().getBag().hero.getItem(heroIdHex);
        if (hero == null) {
            cc.getRole().getGame().notice.message(cc.getRole(), "找不到这个英雄");
            return;
        }
        GameResult<Void> result = hero.newTalentOn.forgetItem(talentIdHex);
        if (!result.ok()) {
            cc.getRole().getGame().notice.message(cc.getRole(), result.message);
        }else {
            cc.getRole().sendNow(new TalentForgetResp(hero.uid, talentIdHex));
        }
    }

    @Override
    public MsgConfig conf() {
        return MsgIdBHeroTalent.TALENT_FORGET_REQ;
    }
}

